package cn.supermaster.management.web.rest.task;

import cn.supermaster.management.common.annotation.Log;
import cn.supermaster.management.common.enums.BusinessType;
import cn.supermaster.management.common.page.TableDataInfo;
import cn.supermaster.management.common.response.WebResponse;
import cn.supermaster.management.schedule.domain.ScheduleTaskLog;
import cn.supermaster.management.web.service.task.ISTaskLogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * All rights Reserved, Designed By www.super-bytecode.com
 *
 * @ProjectName: supermaster-management
 * @Package: cn.supermaster.management.web.rest.task
 * @ClassName: ScheduleTaskLogRestController
 * @Description: []
 * <p> </p>
 * @Author: [Lance Ting]
 * @Date: 2021/2/19 17:36
 * @Version: V1.0
 * @Copyright: 2021 www.super-bytecode.com Inc. All rights reserved.
 * TODO: 注意,本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
@RestController
@RequestMapping("/monitor/jobLog")
public class ScheduleTaskLogRestController {

    @Autowired
    private ISTaskLogService taskLogService;


    @RequiresPermissions("monitor:job:list")
    @PostMapping("/list")
    public TableDataInfo queryScheduleTaskLogList(ScheduleTaskLog taskLog) {
        return taskLogService.queryScheduleTaskLogList(taskLog);
    }


    @Log(title = "调度日志", businessType = BusinessType.EXPORT)
    @RequiresPermissions("monitor:job:export")
    @PostMapping("/export")
    public WebResponse doExportScheduleTaskLog(ScheduleTaskLog taskLog) {
        return taskLogService.doExportScheduleTaskLog(taskLog);
    }

    @Log(title = "调度日志", businessType = BusinessType.DELETE)
    @RequiresPermissions("monitor:job:remove")
    @PostMapping("/remove")
    public WebResponse deleteScheduleTaskLogs(String ids) {
        return taskLogService.deleteScheduleTaskLogs(ids);
    }

    @Log(title = "调度日志", businessType = BusinessType.CLEAN)
    @RequiresPermissions("monitor:job:remove")
    @PostMapping("/clean")
    public WebResponse doCleanScheduleTaskLog() {
        return taskLogService.doCleanScheduleTaskLog();
    }
}